package com.wbl.train.common.member.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @author 王博纶
 * @since 2024-01-26
 * @description 乘车人的实体类
 */
@Data
@Accessors(chain = true)
@Schema(name = "Passenger 对象", description = "乘车人 实体类")
@TableName("passenger") // 设置实体的别名 --- 否则使用mybatisPlus查询的时候会报错
public class PassengerEntity {

    @Schema(description = "id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    // 单独配置，将id的Long类型转换为String类型
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @Schema(description = "会员id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long memberId;

    @Schema(description = "姓名")
    @NotNull(message = "[姓名不能为空]")
    private String name;

    @Schema(description = "身份证")
    @NotNull(message = "[身份证不能为空]")
    @Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\\d|3[0-1])\\d{3}(\\d|X)$",message = "身份证不符合规范")
    private String idCard;

    @Schema(description = "旅客类型|枚举")
    @NotNull(message = "[旅客类型不能为空]")
    private String type;

    @Schema(description = "新增时间")
    private Date createTime;

    @Schema(description = "修改时间")
    private Date updateTime;


}
